<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('转写事件列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>事件ID：</label>
                                <input type="text" name="transferId"/>
                            </li>
                            <li>
                                <label>应用：</label>
                                <select name="productId" id="productId">
                                    <option value="">请选择应用</option>
                                    <option th:each="product:${productList}" th:text="${product.name}" th:value="${product.id}"></option>
                                </select>
                            </li>
                            <li>
                                <label>用户标识：</label>
                                <input type="text" name="userId"/>
                            </li>
                            <li>
                                <label>设备标识：</label>
                                <input type="text" name="deviceId"/>
                            </li>
                            <li>
                                <label>合作方ID：</label>
                                <input type="text" name="providerId"/>
                            </li>
                            <li>
                                开始时间：
                                <input type="text" class="time-input" placeholder="请选择开始时间" id="startCreateTime" name="startCreateTime" th:value="${#dates.format(startCreateTime, 'yyyy-MM-dd')}"/>
                            </li>
                            <li>
                                截止时间：
                                <input type="text" class="time-input" placeholder="请选择结束时间" id="endCreateTime" name="endCreateTime" th:value="${#dates.format(endCreateTime, 'yyyy-MM-dd')}"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

<!--            <div class="btn-group-sm" id="toolbar" role="group">-->
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="product:transfer:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="product:transfer:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="product:transfer:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="product:transfer:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
<!--            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table table-bordered table-hover" style="word-break:break-all;"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('product:transfer:edit')}]];
        var removeFlag = [[${@permission.hasPermi('product:transfer:remove')}]];
        var prefix = ctx + "product/transfer";
        window.onload = function() {
            timeInit();
        }
        function timeInit() {
            var dateEnd = new Date();
            var dateStart = $.common.get7DaysBefore(dateEnd);
            var dateEndStr = $.common.dateFormat(dateEnd, "yyyy-MM-dd");
            var dateStartStr = $.common.dateFormat(dateStart, "yyyy-MM-dd");
            $('#startCreateTime').val(dateStartStr);
            $('#endCreateTime').val(dateEndStr);
        }
        function privateReset() {
            $.form.reset();
            timeInit();
        }
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/form",
                updateUrl: prefix + "/form/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "转写事件",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '${comment}',
                    visible: false
                },
                {
                    field: 'transferId',
                    title: '事件ID'
                },
                {
                    field: 'companyName',
                    title: '转写厂商标识'
                },
                {
                    field: 'productName',
                    title: '应用',
                    width: 100
                },
                {
                    field: 'userId',
                    title: '用户标识',
                    width: 100
                },
                {
                    field: 'deviceId',
                    title: '设备标识',
                    width: 100
                },
                {
                    field: 'transferLanguages',
                    title: '语种'
                },
                {
                    field: 'transferName',
                    title: '文件名称',
                    width: 100
                },
                {
                    field: 'transferFormat',
                    title: '文件格式'
                },
                {
                    field: 'transferSize',
                    title: '文件大小'
                },
                {
                    field: 'transferPath',
                    title: '文件路径',
                    width: 300
                },
                {
                    field: 'transferDuration',
                    title: '录音时长'
                },
                {
                    field: 'transferSampling',
                    title: '采样率'
                },
                {
                    field: 'transferBit',
                    title: 'Bit位'
                },
                {
                    field: 'providerId',
                    title: '合作方ID',
                    width: 100
                },
                {
                    field: 'estimatedTime',
                    title: '预计时长'
                },
                {
                    field: 'status',
                    title: '事件状态',
                    formatter: function(value, row, index) {
                        if(value == 0){
                            return "允许转写";
                        } else if (value == 1) {
                            return "不允许转写";
                        } else if (value == 2) {
                            return "转写中";
                        }  else if (value == 3) {
                            return "转写失败";
                        }  else if (value == 4) {
                            return "获得完成回调";
                        }  else if (value == 5) {
                            return "转写完成";
                        }  else {
                            return "--";
                        }
                    },
                    width: 100
                },
                {
                    field: 'transferApi',
                    title: '转写API',
                    width: 200
                },
                {
                    field: 'resultCode',
                    title: '结果'
                },
                {
                    field: 'resultContent',
                    title: '结果内容',
                    width: 100,
                    formatter: function(value, row, index) {
                        if (value != null) {
                            return '<a href="javascript:void(0)" onclick="lookDesc(\'' + row.id + '\')">查看</a>';
                        }
                    }
                },
                {
                    field: 'failReason',
                    title: '失败原因',
                    width: 100
                },
                {
                    field: 'resultTime',
                    title: '结果时间',
                    width: 100
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    width: 100
                },
                {
                    field: 'realDuration',
                    title: '实际时长'
                // },
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     }
                },
                {
                    field: 'originDuration',
                    title: '原始时长'
                }
                ]
            };
            $.table.init(options);
        });
        function lookDesc(id) {
            $.modal.open("详情",prefix + "/lookDesc/" + id);
        }
    </script>
</body>
</html>